const app = getApp()

Page({
    data: {
        TabCur: 0,
        scrollLeft: 0,
        tablist: ["推荐", "健身", "游戏", "影视", "音乐", "汽车", "数码", "美食"],
        allnoteList: [{
                coverUrl: "/image/jett太可爱了🥺_1_chamber-_-_来自小红书网页版.jpg",
                title: "生气的Jeet",
                headUrl: "/image/jeet.jpg",
                userName: "赵",
                likeNum: "136",
                islike: "1",
                category: [0]
            },
            {
                coverUrl: "/image/Kyrie WallPaper 高清_1_籃球人🏀_来自小红书网页版.jpg",
                title: "Kyrie Lrving",
                headUrl: "/image/Kyrie.jpg",
                userName: "欧文中文网",
                likeNum: "2.6w",
                islike: "1",
                category: [0,]
            },
            {
                coverUrl: "/image/这么帅气的彭于晏你不看看吗🧐_1_快乐娱悦_来自小红书网页版.jpg",
                title: "不是，谁把我照片发出来了",
                headUrl: "/image/彭于晏.jpg",
                userName: "娱乐小圈",
                likeNum: "7w",
                islike: 1,
                category: [1]
            },
            {
                coverUrl: "/image/这张真的好帅啊啊啊啊我伦😭_1_路小雨写立可白i_来自小红书网页版.jpg",
                title: "白毛伦YYDS",
                headUrl: "/image/路小雨.jpg",
                userName: "小雨写可对白",
                likeNum: "51w",
                islike: "1",
                category: [0,4]
            },
            {
                coverUrl: "/image/《复仇者联盟》——超级英雄的集结_1_国小传日记_来自小红书网页版.jpg",
                title: "复仇者联盟集合！",
                headUrl: "/image/国小转.jpg",
                userName: "影视风暴",
                likeNum: "63w",
                islike: "1",
                category: [0,3]
            }
        ]
    },
    tabSelect(e) {
      let list = this.data.allnoteList;
      let categoryId = e.currentTarget.dataset.id;
      let newList = [];
      for (let index = 0; index < list.length; index++) {
        if (!(list[index].category.indexOf(categoryId) == -1)){
            newList.push(list[index])
        }
    }
        this.setData({
            TabCur: e.currentTarget.dataset.id,
            scrollLeft: (e.currentTarget.dataset.id - 1) * 60,
            noteList:newList
        })
    },
    //分类0为推荐，
    onLoad(options) {
        let list = this.data.allnoteList;
        let newList = [];
        for (let index = 0; index < list.length; index++) {
            if (!(list[index].category.indexOf(0) == -1)){
                newList.push(list[index])
            }
        }
        this.setData({
            noteList: newList
        })
    },
})